#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int gcd(int x, int y)
{
	while (y != 0)
	{
		int temp = y;
		y = x % y;
		x = temp;
	}
	return x;
}
int main()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	int c = 0;
	c = gcd(a,b);
	printf("%d", c);
	return 0;
}